package com.example.wengwyue.patientapplication.network;

import com.hospital.common.api.CallbackUtils;
import com.hospital.common.api.DataCallback;
import com.hospital.common.api.ObjectCallback;
import com.hospital.common.api.secure.AESKey;
import com.zhy.http.okhttp.callback.StringCallback;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by lingquan(quan.ling@hotmail.com) on 16/8/14.
 */
public class UserApi {

    /**
     * 获取验证码
     *
     * @param callback
     */
    public static void sendVerifyCode(CharSequence phone, final StringCallback callback) {
        CallbackUtils.get(API.SEND_VERIFY_CODE + "/" + phone, callback);
    }

    public static void preRegister(String p, ObjectCallback<Void> callback) {
        JSONObject obj = new JSONObject();
        try {
            obj.put("data", p);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        CallbackUtils.post(API.PRE_REGISTER, obj.toString(), callback);
    }

    public static void detailRegister(String name, AESKey key, String p, DataCallback callback) {
        JSONObject obj = new JSONObject();
        try {
            obj.put("data", p);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        CallbackUtils.post(API.DETAIL_REGISTER, obj.toString(), name, key, callback);
    }

}
